<%--
  Created by IntelliJ IDEA.
  User: cuirj
  Date: 2021/10/11
  Time: 8:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>修改密码</title>
    <link href="<%=basePath%>/css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
    <script type="text/javascript">
        $(function(){
            $('tbody tr:odd').addClass("trLight");

            $(".select-all").click(function(){
                if($(this).attr("checked")){
                    $(".checkBox input[type=checkbox]").each(function(){
                        $(this).attr("checked", true);
                    });
                }else{
                    $(".checkBox input[type=checkbox]").each(function(){
                        $(this).attr("checked", false);
                    });
                }
            });

        });
        function checkpwd(){
            $("#msg").text("");
            var old_password = $("#oldpwd").val();
            var user_id = $("#userId").val();
         //校验原密码是否正确，采用ajax请求
            $.ajax({
                url:"<%=basePath%>checkoldPassword",
                dataType : "json",
                data:{"oldpassword":old_password,"id":user_id},
                //编码设置
                contentType : "application/json;charset=utf-8",
                success : function(data) {
                    if (data.msg != null) {
                        $("#msg").append(data.msg);
                        $("#oldpwd").val("");
                        $("#oldpwd").focus();
                    }
                },
                error:function(){
                    alert("后台服务器出错，请联系系统管理员！");
                }
            })



        }
        function confirmpwd(){
            var password_1 = $("#password1").val();
            var password_2 = $("#password2").val();
            if(password_1!="" && password_2!="" && password_1!= password_2){
                alert("两次输入的密码不一致，请重新输入");
                $("#password2").val("");
                $("#password2").focus();
                return false;
            }
        }
    </script>
    <style type="text/css">
        body {
            background:#FFF
        }
    </style>
</head>
<body>
<form method="post" action="<%=basePath%>updatepdwContrller" method="post" name="ThisForm">
    <input type="hidden" name="id" id="userId" value="${suser.id}"/>
    <div id="contentWrap">
        <!--表格控件 -->
        <div id="widget table-widget">
            <div class="pageTitle">密码修改</div>
            <div class="pageInfo">
                <table>
                     <tr>
                        <td width="20%" align="right">登录名</td>
                        <td width="20%"><input type="text" id="username" name="username" value="${suser.username}" readonly/></td>
                    </tr>
                    <tr>
                        <td width="20%" align="right">原始密码</td>
                        <td width="20%"><input type="password" id="oldpwd" name="oldpwd"  onchange="checkpwd()"/>
                        <label id="msg"></label></td>
                    </tr>
                    <tr>
                        <td width="20%" align="right">新密码</td>
                        <td width="20%"><input type="password" id="password1" name="password1" /></td>
                    </tr>
                    <tr>
                        <td width="20%" align="right">密码确认</td>
                        <td width="20%"><input type="password" id="password2" name="password2"  onchange="confirmpwd()"/></td>
                    </tr>
                    <tr>
                        <td colspan="2"  align="center"><input type="submit" value="确定" /></td>
                    </tr>
                </table>
            </div>
        </div><!-- #widget -->
    </div>

</form>
</body>
</html>
